#include "ColourPicker.h"

ColourPicker::ColourPicker()
{
}
ColourPicker::~ColourPicker()
{
}

bool ColourPicker::GetSelectedColour(D3DXCOLOR a_inColor, D3DXCOLOR& a_color)
{
	CHOOSECOLOR cc;
	COLORREF cr[] = { RGB(0,     5,   5),
		RGB(0,    15,  55),
		RGB(0,    25, 155),
		RGB(0,    35, 255),
		RGB(10,    0,   5),
		RGB(10,   20,  55),
		RGB(10,   40, 155),
		RGB(10,   60, 255),
		RGB(100,   5,   5),
		RGB(100,  25,  55),
		RGB(100,  50, 155),
		RGB(100, 125, 255),
		RGB(200, 120,   5),
		RGB(200, 150,  55),
		RGB(200, 200, 155),
		RGB(200, 250, 255) };

	ZeroMemory(&cc, sizeof(CHOOSECOLOR));

	cc.lStructSize = sizeof(CHOOSECOLOR);
	cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
	cc.rgbResult = RGB(a_inColor.r*255, a_inColor.g*255, a_inColor.b*255);
	cc.lpCustColors = cr;

	if(ChooseColor(&cc))
	{
		m_selectedColour = cc.rgbResult;
		a_color = D3DCOLOR_XRGB(GetRValue(m_selectedColour), GetGValue(m_selectedColour), GetBValue(m_selectedColour));
		return true;
	}
	//Colour picker cancelled or closed
	return false;
}